package hu.intro.dopamine.gigme.views;

import hu.intro.dopamine.gigme.GigmeController;
import hu.intro.dopamine.gigme.utils.ImageUtil;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class SplashCanvas extends Canvas {

	GigmeController controller;
	Image logoImage;

	public SplashCanvas(GigmeController controller) {
		this.controller = controller;
		this.setFullScreenMode(true);
		
        logoImage = ImageUtil.loadImage("/img/gigme.png");
	}

	protected void paint(Graphics g) {
		g.setColor(0xFF8AF8);
		g.fillRect(0, 0, getWidth(), getHeight());

		g.drawImage(logoImage, getWidth()/2, getHeight()/2, Graphics.HCENTER|Graphics.VCENTER);
        
        g.setColor(0xFFFFFF);
        Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL );
        g.setFont( font );
        int fontHeight = font.getHeight();
        String copyright = "Hello World!";
        int copyWidth = font.stringWidth(copyright);
        g.drawString(copyright, getWidth()/2 - copyWidth/2, getHeight()-fontHeight*2, Graphics.LEFT|Graphics.BOTTOM);
        String urlLink = "dopamine.intro.hu ^ last.fm";
        int urlWidth = font.stringWidth(urlLink);
        g.drawString(urlLink, getWidth()/2 - urlWidth/2, getHeight()-fontHeight, Graphics.LEFT|Graphics.BOTTOM);


	}

    protected void keyPressed(int keyCode) {
        this.controller.showMain();
    }
}
